package com.ruyuan.eshop.common.domain.entity;

import com.ruyuan.eshop.common.enums.TradeTypeEnum;
import com.ruyuan.eshop.framework.domain.entity.BaseEntity;
import lombok.Data;

/**
 * 支付帐单实体
 * 商品类型枚举
 * @author pwd
 * @version 1.0
 */
@Data
public class PaymentBillDO extends BaseEntity {


    private Long billId;

    /**
     * 交易单号
     */
    private String subSn;

    /**
     * 支付账单编号（提交给第三方平台单号）
     */
    private String billSn;

    /**
     * 第三方平台返回交易号
     */
    private String returnTradeNo;

    /**
     * 是否已支付
     */
    private Integer isPay;

    /**
     * 交易类型
     */
    private String serviceType;

    /**
     * 支付方式名称
     */
    private String paymentName;

    /**
     * 支付参数
     */
    private String payConfig;

    /**
     * 交易金额
     */
    private Double tradePrice;

    /**
     * 支付插件id
     */
    private String paymentPluginId;

    public PaymentBillDO() {
    }

    public PaymentBillDO(String subSn, String billSn, String returnTradeNo, Integer isPay, String serviceType, String paymentName, Double tradePrice, String paymentPluginId) {
        this.subSn = subSn;
        this.billSn = billSn;
        this.returnTradeNo = returnTradeNo;
        this.isPay = isPay;
        this.serviceType = serviceType;
        this.paymentName = paymentName;
        this.tradePrice = tradePrice;
        this.paymentPluginId = paymentPluginId;
    }

    public PaymentBillDO(TradeDO tradeDO) {
        this.subSn = tradeDO.getTradeSn();
        this.tradePrice = tradeDO.getTotalPrice();
        this.serviceType = TradeTypeEnum.TRADE.name();
        this.isPay = 0;
    }

    public PaymentBillDO(OrderDO orderDO) {
        this.subSn = orderDO.getTradeSn();
        this.tradePrice = orderDO.getNeedPayMoney();
        this.serviceType = TradeTypeEnum.ORDER.name();
        this.isPay = 0;
    }

    public  PaymentBillDO(String subSn,Double price,String type){
        this.subSn = subSn;
        this.tradePrice = price;
        this.serviceType = type;
        this.isPay = 0;
    }
}